package com.xy.config;

import com.xy.properties.EmsServerProperties;
import com.xy.service.UserInfoApi;
import com.xy.service.impl.UserInfoApiImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xxy
 * @date 2022/1/6 14:38
 */
@ConditionalOnClass({UserInfoApi.class})
@Configuration
@EnableConfigurationProperties({EmsServerProperties.class})
public class EmsServerAutoConfiguration {

    private final EmsServerProperties emsServerProperties;

    public EmsServerAutoConfiguration(EmsServerProperties emsServerProperties) {
        this.emsServerProperties = emsServerProperties;
    }


    @Bean
    @ConditionalOnMissingBean
    public UserInfoApi userInfoApi(){
        return new UserInfoApiImpl(emsServerProperties);
    }

}
